<!DOCTYPE html>
<html>
  <head>
  	<div th:include="base-libs :: base-libs" />
    <title>删除已分配任务</title>
	
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
    
    <style>
    	#north{
			height:47px;
			line-height:47px;
			font-size:16px;
			padding-left:35px;
			overflow:hidden;
			border:0;
		}
    	#fixedBox{
			text-align:right;
			overflow:hidden;
			border:0;
			padding-right:30px;
			border-top:1px solid #ddd;
		}
		#cancel{
			border: 1px solid #dedede;
		    background-color: #f1f1f1;
		    color: #333;
		}
    </style>
    
	<script>
		$(function(){
			initView();
			initData();
		})
		
		function initData(){
    		var deleteData = StoreCache.removeCache("deleteData");
    		$("#deleteTotal").html(deleteData.length);
    		$("#deleteTable").datagrid('loadData',deleteData);
    	}
		
		function initView(){
			$("#deleteTable").datagrid({
				idField : "FWID",
				striped : true,
				clickToSelect: true,
				fitColumns: true,
				fit:true,
				border:false,
				scrollbarSize:0,
				singleSelect:true,
				columns : [[
					{field : "XM",title : "签约居民",width:40, align:'center'},
					{field : "FWMC",title : "服务项",width:60, align:'center'},
					{field : "FWNR",title : "服务项内容",width:120, align:'center'},
					{field : "QYTD",title : "新增服务(次数)",width:60, align:'center',formatter:function(){
						return 1;
					}},
					{field : "USERID",title : "服务人员",width:60, align:'center',formatter: function(value, row){
						var tdryData = row.tdryData;
						$.each(tdryData, function(i,item){
							if(item.USERID==value){
								value = item.XM;
							}
						})
						return value;
					}},
					{field : "YQFWSJ",title : "预期服务时间",width:60, align:'center', formatter:function(value){
						if(!StringUtils.isEmpty(value)){
							return value.substring(0,10);
						}
					}},
					{field : "FWDX",title : "服务对象",width:60, align:'center'},
				]],
				method : "post"
			}); 
		}
		
		/** 确认删除  */
		function confirmDelete(){
			var deleteData = $("#deleteTable").datagrid("getRows");
			$.QuickRemote.AjaxJson(contextRoot + "wdqyhz/deleteYfprw", function(result){
				if(result.state){
					$.QuickAlert.alertNormal("删除成功",{callback: function(){
						StoreCache.setCache("refresh",true);
						parent.layer.closeAll();
						
					}});
				}else{
					var info = result["info"];
					$.QuickAlert.alertFail({content: info["faultInfo"]});
				}
			}, {deleteData: JSON.stringify(deleteData)});
		}
		
		/** 取消  */
		function cancel(){
			parent.layer.closeAll();
		}
	</script>
  </head>
  
  <body class="easyui-layout" fit="true" style="overflow:hidden;overflow:hidden">
		<div region="north" id="north">
			您已选中<span style="color:red" id="deleteTotal"></span>条记录，
			是否确认删除该服务？
		</div>
		<div region="center" style="height:400px;overflow:auto;border:0;">
			<table id="deleteTable"></table>
		</div>
		<div region="south" id="fixedBox" class="layui-layer-btn" style="height:50px;line-height:50px;">
			<button class="layui-layer-btn0" type="button" onclick="confirmDelete()">确认</button>
			<button id="cancel" class="layui-layer-btn1" type="button" onclick="cancel()">取消</button>
		</div>
  </body>
</html>
